<?php
require $root.'/ArrayStruct/ArrayStruct.php';
require 'Queue.php';
class QueueStruct implements Queue
{
    protected $array = null;

    public function __construct(int $capacity = 0)
    {
        $this->array = new ArrayStruct($capacity);
    }

    /**
     * 入队
     * @param $e
     * @throws Exception
     */
    public function enqueue($e): void
    {
        $this->array->addLast($e);
    }

    /**
     * 出队
     */
    public function dequeue()
    {
        return $this->array->removeFirst();
    }

    /**
     * 获取队前元素
     */
    public function getFront()
    {
        return $this->array->getFirst();
    }

    /**
     * 获取队列大小
     * @return int
     */
    public function getSize(): int
    {
        return $this->array->getSize();
    }

    /**
     * 判断队列是否为空
     * @return bool
     */
    public function isEmpty(): bool
    {
        return $this->array->isEmpty();
    }

    /**
     * 打印队列内容
     * @return bool
     */
    public function toString(): string
    {
        return $this->array->toString();
    }
}